﻿<!-- _meta 作为公共模版分离出去 -->
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp"/>
	<link rel="Shortcut Icon" href="/admin/imgs/logo.ico"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css"/>
	<title>大会后台</title>
	<style type="text/css">
		#lng, #lat { width: 100px; }
		#gaode { width: 150%; min-height: 400px; border-radius: 5px; border: 1px solid #CCC; box-shadow: 0 0 5px #888; }
	</style>

	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<!--<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script>-->
	<script type="text/javascript" src="js/admin.js"></script>
	<script type="text/javascript">
	</script>
</head>
<body>
<section class="Hui-article-box" style="position:relative;top:0;left:0;">
	<nav class="breadcrumb" style="color:#888;">
		<i class="Hui-iconfont">&#xe67f;</i>
		<a href="main.html" class="maincolor">首页</a>
		<span class="c-gray en">&gt;</span>
		前台
		<span class="c-gray en">&gt;</span>
		联系我们
	</nav>
</section>
<div class="page-container" style="margin:10px 10%;width:50%;position:relative;top:50px;left:0;">
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			公司中文名：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" id="gscn">
		</div>
	</div>
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			公司英文名：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" id="gsen">
		</div>
	</div>
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			公司座机：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" id="tel">
		</div>
	</div>
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			公司邮箱：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" id="email">
		</div>
	</div>
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			公司地址：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" id="dz01" placeholder="地址1" value="120.136756" />
			<div style="height:5px;"></div>
			<input type="text" class="input-text" id="dz02" placeholder="地址2"/>
		</div>
	</div>
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			地图坐标：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			经度：<input type="text" class="input-text" id="lng"/>
			纬度：<input type="text" class="input-text" id="lat"/>
			<div style="height:5px;"></div>
			<div id="gaode"></div>
		</div>
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
			<button onClick="save()" class="btn btn-secondary radius" type="button">立即保存</button>
		</div>
	</div>
</div>

<span id="pop"></span>
</body>
</html>


<script src="//webapi.amap.com/maps?v=1.3&key=4a6afccb448ee271ce2f43e1715cd877"></script>
<script src="//webapi.amap.com/ui/1.0/main.js"></script>
<script type="text/javascript" src="http://webapi.amap.com/demos/js/liteToolbar.js"></script>
<!--<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>-->
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<script type="text/javascript">
	var map;
	var lng = '120.136756', lat = '30.284112';
	(function(){
		getOne();
		setTimeout("gaode()", 1000);
		// gaode();
	})();
	//获取高德坐标
	function gaode(){
		// console.log(lng,lat);
		var map = new AMap.Map('gaode', {
			resizeEnable: true,
			zoom: 20,
			// center: [120.136756, 30.284112]
			center: [lng, lat]
		});
		AMap.plugin('AMap.ToolBar', function() {
			var toolbar = new AMap.ToolBar();
			map.addControl(toolbar)
		});
		var marker = new AMap.Marker({
			position: map.getCenter(), //标记的位置坐标
			offset: new AMap.Pixel(-5, -5), //标记相对位置的偏移，对应style的left和top
			icon: ico, //创建好的icon，也可以在后面使用setIcon()方法添加
			zoom: 13
		});
		marker.setLabel({
			offset: new AMap.Pixel(10, 30)
		});
		var ico = new AMap.Icon({
			size: new AMap.Size(20, 30), // 图标尺寸
			image: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_bs.png', // Icon的图像
			imageOffset: new AMap.Pixel(0, 0), // 图像相对展示区域的偏移量，适于雪碧图等
			imageSize: new AMap.Size(20, 30) // 根据所设置的大小拉伸或压缩图片，对应style的width和height
		});
		map.add(marker); //将创建好的marker放到地图上面
		AMap.event.addListener(map, 'click', function (e) {//点击事件
			map.clearMap();
			var x = e.lnglat.getLng();
			var y = e.lnglat.getLat();
			marker = new AMap.Marker({
				position:[x,y], //标记的位置坐标
				offset: new AMap.Pixel(-5, -5), //标记相对位置的偏移，对应style的left和top
				icon: ico, //创建好的icon，也可以在后面使用setIcon()方法添加
				zoom: 13
			});
			map.add(marker);
			document.getElementById("lng").value = x;
			document.getElementById("lat").value =y;
		});
	}
//	//地图搜索
//	function mapsearch(){
//		var searchVal = $("#mymap_search").val();
//		placeSearch.search(searchVal);
//	}
//	// 回显
//	function myMapViewLocation(){
//		//console.log("回显坐标");
//		var mlon = $("input[name=lon]").val();
//		var mlat = $("input[name=lat]").val();
//		var lnglatXY = [mlon,mlat];
//		if(mlon&&mlat){
//			addMarker(lnglatXY);
//		}
//	}
//	// 实例化点标记
//	function addMarker(lnglatXY) {
//		//console.log(lnglatXY);
//		marker = new AMap.Marker({
//			icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
//			position: lnglatXY
//		});
//		marker.setMap(map);
//		map.setFitView();// 执行定位
//	}
	//获取联系方式
	function getOne(){
		var formData = {};
		$.ajax({
			type: 'post',
			url: domain+'lianxi/one',
			data: formData,
			success: function (res) {
				res = JSON.parse(res);
				console.log(res);
				if (res.code!=0) {
					pop({msg:res.msg}); return
				}
				var d = res.data;
				$('#gscn')[0].value = d.gscn;
				$('#gsen')[0].value = d.gsen;
				$('#tel')[0].value = d.tel;
				$('#email')[0].value = d.email;
				// $('#dz01')[0].value = lng = d.dizhi01;
				// $('#dz02')[0].value = lat = d.dizhi02;
				$('#dz01')[0].value = lng = d.lng;
				$('#dz02')[0].value = lat = d.lat;
				$('#lng')[0].value = d.lng;
				$('#lat')[0].value = d.lat;
			},
			error: function () {
				console.log('网络错误');
			}
		});
	}
	//保存
	function save(){
		var gscn = $('#gscn').val();
		var gsen = $('#gsen').val();
		var tel = $('#tel').val();
		var email = $('#email').val();
		var dz01 = $('#dz01').val();
		var dz02 = $('#dz02').val();
		var lng = $('#lng').val();
		var lat = $('#lat').val();
		if (gscn=='') { pop({msg:'公司中文名未填写'}); return }
		if (gsen=='') { pop({msg:'公司英文名未填写'}); return }
		if (tel=='') { pop({msg:'座机未填写'}); return }
		if (email=='') { pop({msg:'邮箱未填写'}); return }
		if (dz01=='') { pop({msg:'地址1未填写'}); return }
		if (dz02=='') { pop({msg:'地址2未填写'}); return }
		if (lng=='') { pop({msg:'坐标经度未填写'}); return }
		if (lat=='') { pop({msg:'坐标纬度未填写'}); return }
		var formData = {
			gscn: gscn, gsen: gsen, tel: tel,
			email: email, dz01: dz01, dz02: dz02,
			lng: lng, lat: lat,
		};
		$.ajax({
			type: 'post',
			url: domain+'lianxi/modify',
			data: formData,
			success: function (res) {
				res = JSON.parse(res);
				console.log(res);
				if (res.code!=0) {
					pop({msg:res.msg}); return;
				}
				pop({msg:'成功'});
				setTimeout(function(){
					window.location.href = '';
				},1000);
			},
			error: function () {
				console.log('网络错误');
			}
		});
	}
</script>